<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>sort-优化</title>
</head>
<body>
<script>
    var arr3 = [5, 2, 11, 3, 4, 1];
    var result = arr3.sort(function(a, b) {
        return a - b; // 升序排列
        // return b - a; // 降序排列
    });

    console.log("arr3 =" + JSON.stringify(arr3));
    console.log("result =" + JSON.stringify(result));
</script>
</body>
</html>